package daily_exercise;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        String className = "daily_exercise.User1";
        // 获取Class对象
        Class clazz = Class.forName(className);
        // 创建User对象
        User1 user = (User1)clazz.newInstance();
        // 和普通对象一样，可以设置属性值
        user.setUsername("yangwenqiang");
        user.setPassword("19931020");

        System.out.println(user);
    }
}

class User1 {
    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User [username=" + username + ", password=" + password + "]";
    }
}
